<extend name="work/base"/>
<block name="content">
    <div class="layui-tab layui-tab-brief" lay-filter="tagtab">
        <ul class="layui-tab-title">
            <volist name="tag_list" id="vo" key="k">
                <li lay-id="{$vo.tag_id}">{$vo.name}</li>
            </volist>
        </ul>
        <div class="layui-tab-content">
            <volist name="tag_list" id="vo" key="k">
                <div class="layui-tab-item">
                    <div class="pull-right">
                        <div class="layui-inline">
                            <button class="layui-btn layui-btn-normal layui-btn-sm ajax-form"
                                    data-url="{:url('c_wx_menu?tag_id='.$vo['tag_id'])}"><i
                                    class="layui-icon">&#xe61f;</i> 生成微信菜单
                            </button>
                        </div>
                    </div>
                </div>
            </volist>
        </div>
    </div>
    <table class="layui-table text-center" id="list" lay-filter="list" list-url="{:url('lists')}"
           edit-url="{:url('edit')}" assigned-url="{:url('editcategory')}" del-url="{:url('delete')}"></table>
</block>
<block name="script">
    <script type="text/html" id="barDemo">
        <a class="layui-btn  layui-btn-xs" lay-event="assigned">编辑</a>
    </script>
    <script type="text/html" id="view1">
        <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="正常|禁用" lay-filter="is_view" {{
               d.status== 1?'checked' : '' }}>
    </script>
    <script type="text/html" id="view2">
        {{ d.pid==0?'一级菜单':d.p_name}}
    </script>
    <script type="text/javascript">
        layui.use(['element', 'table'], function () {
            var table = layui.table
                , element = layui.element;
            var tag_id = 0;
            element.on('tab(tagtab)', function () {
                tag_id = Number(this.getAttribute('lay-id'));
                table.reload('list', {
                    url: "{:Url('lists')}"
                    ,page:false
                    , where: {
                        tag_id: tag_id,
                    }
                });
            });
            element.tabChange('tagtab', 0);
            table.render({
                elem: '#list'
                , page: false
                , loading: true
                , url: "{:Url('lists')}"
                , where: {
                    tag_id: tag_id,
                }
                ,limit:20
                , cols: [[
                    {field: 'p_name', width: 150, title: '一级菜单', templet: '#view2'}
                    , {field: 'name', width: 150, title: '菜单名称', edit: 'text'}
                    , {field: 'msg', width: 150, title: '说明'}
                    , {field: 'status', width: 110, title: '状态', templet: '#view1'}
                    , {field: 'type', width: 130, title: '类型'}
                    , {field: 'info', title: '动作', edit: 'text'}
                    , {fixed: 'right', width: 100, title: '操作', toolbar: '#barDemo'}

                ]]
            });
        });
    </script>
</block>
